﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Uco.Models;
using System.Data;
using System.IO;
using System.Collections;
using Uco.Infrastructure;

namespace Uco.Areas.Admin.Controllers
{
    [Authorize]
    public class SettingsController : BaseAdminController
    {

        public ActionResult Index()
        {
            return View(SF.GetSettingsRepository());
        }

        [HttpPost]
        public ActionResult Index(Settings s)
        {
            if (ModelState.IsValid)
            {
                SF.SaveSettings(s);

                CleanCache.CleanSettingsCache();

                return RedirectToAction("Index", "Main");
            }
            else return View();
        }

        [HttpGet]
        public ActionResult AplicationClear()
        {
            return View();
        }

        [HttpPost]
        public ActionResult AplicationClear(bool Memory, bool Images, bool Menu)
        {
            if (Memory) CleanCache.RestartApplication();
            if (Menu) CleanCache.CleanMenuCache();
            if (Images) CleanCache.CleanImageCache();

            return RedirectToAction("AplicationClearDone");
        }

        [HttpGet]
        public ActionResult AplicationClearDone()
        {
            return View();
        }
    }
}
